﻿    using Efcore_Test.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Efcore_Test.Data.config
{
    public class ArticleConfig : IEntityTypeConfiguration<Article>
    {
        public void Configure(EntityTypeBuilder<Article> builder)
        {
            builder.ToTable("T_Article");
            builder.Property(x => x.Title).HasMaxLength(100).IsUnicode();
            //配置乐观锁     
            //builder.Property(h => h.version).IsConcurrencyToken();
            builder.Property(h => h.version).IsRowVersion();
            //builder.HasMany(x => x.Comments).WithOne(c => c.Article).HasForeignKey(x => x.ArticleId).IsRequired(); //1对多
        }
    }
}
